var rule = {
	// 
	validate(params) {
		let flag = false;
		let values = [{
			name: '请输入商品名称',
			value: 'productName',
			callback: function (e) {
				return e != '';
			}
		},
		{
			name: '请上传商品主图',
			value: 'image',
			callback: function (e) {
				return e.length > 0;
			}
		},
		{
			name: '请上传商品视频封面',
			value: 'posterId',
			callback: function (e) {
				if (params.videoId > 0) {
					return e != '';
				} else {
					return true
				}

			}
		},
		{
			name: '请选择商品分类',
			value: 'categoryId',
			callback: function (e) {
				return e != '';
			}
		},
		{
			name: '请输入限购数量',
			value: 'limitNum',
			callback: function (e) {
				return e !== '';
			}
		},
		{
			name: '请输入商品排序',
			value: 'productSort',
			callback: function (e) {
				return e >= 0;
			}
		},
		{
			name: '请输入虚拟内容',
			value: 'virtualContent',
			callback: function (e) {
				if (params.isVirtual == 1) {
					return e != '';
				} else {
					return true
				}
			}
		},
		{
			name: '请输入最大抵扣积分数量',
			value: 'maxPointsDiscount',
			callback: function (e) {
				if (params.isPointsDiscount == 1) {
					return e >= 0;
				} else {
					return true
				}
			}
		},
		{
			name: '请选择运费模板',
			value: 'deliveryId',
			callback: function (e) {
				if (params.isVirtual == 0 && params.isDeliveryFree == 1) {
					return e > 0;
				} else {
					return true
				}
			}
		},
		{
			name: '请输入产品编码',
			value: 'sku.productNo',
			callback: function (e) {
				if (params.specType == 10) {
					return e !== '';
				} else {
					return true
				}
			}
		},
		{
			name: '请输入产品价格',
			value: 'productPrice',
			callback: function (e) {
				if (params.specType == 10) {
					return params.productPrice != '';
				} else {
					return true
				}
			}
		},
		{
			name: '请输入产品划线价',
			value: 'linePrice',
			callback: function (e) {
				if (params.specType == 10) {
					return params.linePrice != '';
				} else {
					return true
				}
			}
		},
		{
			name: '请输入库存数量',
			value: 'stockNum',
			callback: function (e) {
				if (params.specType == 10) {
					return params.stockNum != '';
				} else {
					return true
				}
			}
		},
		{
			name: '请输入商品重量',
			value: 'productWeight',
			callback: function (e) {
				if (params.specType == 10) {
					return params.productWeight != '';
				} else {
					return true
				}
			}
		}
		];
		values.forEach((item, index) => {
			if (!flag && !item.callback(params[item.value])) {
				flag = item.name;
				return;
			}
		});
		if (flag) {
			uni.showToast({
				title: flag,
				duration: 1000,
				icon: 'none'
			});
			return false;
		}
		return true
	},
}
export default rule;
